package com.example.task10.controller;

import com.example.task10.entity.Student;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/student")
public class StudentController {
    @RequestMapping("/test")
    public String test(){
        return "ok";
    }


    @Autowired
    JdbcTemplate jdbcTemplate;

    /**
     * 全表查询
     * @return
     */
    @GetMapping("/selectList")
    public List<Map<String, Object>> selectList(){
        String sql = "select * from student";

        List<Map<String, Object>> maps = jdbcTemplate.queryForList(sql);

        return maps;
    }
}
